<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="政治面貌" prop="politics">
        <el-input
          v-model="queryParams.politics"
          placeholder="请输入政治面貌"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学历" prop="degree">
        <el-input
          v-model="queryParams.degree"
          placeholder="请输入学历"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="memberList">
      <el-table-column label="序号" align="center" width="55" prop="sn"/>
      <el-table-column label="姓名" align="center" width="100" prop="name"/>
      <el-table-column label="性别" align="center" width="50" prop="sex"/>
      <el-table-column label="出生年月" align="center" width="75" prop="birthday"/>
      <el-table-column label="学历" align="center" width="70" prop="degree"/>
      <el-table-column label="政治面貌" align="center" width="80" prop="politics"/>
      <el-table-column label="政治安排" align="center" prop="arrange"/>
      <el-table-column label="社会职务" align="center" prop="position"/>
      <el-table-column label="工作单位及职务" align="center" min-width="160" prop="workplace" show-overflow-tooltip/>
      <el-table-column label="身份类别" align="center" prop="type">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_eval_type" :value="scope.row.type"/>
        </template>
      </el-table-column>
      <el-table-column label="综合评价" align="left" min-width="160" prop="score">
        <template slot-scope="scope">
         <span style="color: red;font-weight: bold">{{scope.row.score?scope.row.score:"未评价"}}</span>{{scope.row.ext1?"(说明："+scope.row.ext1+")":""}}
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" width="50"  fixed="right" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            v-hasPermi="['evaluation:member:edit']"
          >查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 评价总览-->
    <el-drawer
      title="评价总览"
      :visible.sync="drawer"
      size="50%"
      direction="rtl">
      <el-descriptions style="padding: 0px 15px;" labelClassName="custom-label" title="张三的综合评价" :column="3"
                       size="medium" border>
        <el-descriptions-item label="姓名">{{ form.name }}</el-descriptions-item>
        <el-descriptions-item label="性别">{{ form.sex }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{ form.phone }}</el-descriptions-item>
        <el-descriptions-item label="出生年月">{{ form.birthday }}</el-descriptions-item>
        <el-descriptions-item label="名族">{{ form.ethnicity }}</el-descriptions-item>
        <el-descriptions-item label="政治面貌">{{ form.politics }}</el-descriptions-item>
        <el-descriptions-item label="学历">{{ form.degree }}</el-descriptions-item>
        <el-descriptions-item label="籍贯">{{ form.origin ? form.origin : '无' }}</el-descriptions-item>
        <el-descriptions-item label="政治安排">{{ form.arrange ? form.arrange : '无' }}</el-descriptions-item>
        <el-descriptions-item label="社会职务">{{ form.position ? form.position : '无' }}</el-descriptions-item>
        <el-descriptions-item label="身份证号码">{{ form.idcard ? form.idcard : '无' }}</el-descriptions-item>
        <el-descriptions-item label="身份类别">
          <dict-tag
            :options="dict.type.sys_eval_type"
            :value="form.type"
          />
        </el-descriptions-item>
        <el-descriptions-item label="工作单位及职务">{{ form.workplace }}</el-descriptions-item>
      </el-descriptions>
      <!-- 评价结果-->
      <el-descriptions style="padding: 15px 15px;" labelClassName="custom-label-2" :column="1" size="medium" border>
        <el-descriptions-item :label="item.evaluateName" v-for="item in overviewForm">
          单位：{{ item.deptContent ? item.deptContent : '暂无评价' }}，
          自我评价：{{ item.selfScore ? item.selfScore : '无' }}，综合评价：<span
          style="color: red;font-weight: bold">{{ item.comScore ? item.comScore : '无' }}</span>{{item.comContent ? "(说明：" + item.comContent + ")":""}}</el-descriptions-item>
        <el-descriptions-item label="综合评价结果"><span style="color: red;font-weight: bold">{{ form.score?form.score:"未评价" }}</span>
          {{form.ext1?"(说明："+form.ext1+")":""}}
        </el-descriptions-item>
      </el-descriptions>
    </el-drawer>
  </div>
</template>

<script>
import {
  listMember,
  overview
} from "@/api/evaluation/member";

export default {
  name: "Index",
  dicts: ['sys_eval_sex', 'sys_eval_type', 'sys_eval_politics', 'sys_eval_qualification', 'sys_eval_ethnicity'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 待评价人员表格数据
      memberList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        idcard: null,
        sn: null,
        sex: null,
        birthday: null,
        ethnicity: null,
        politics: null,
        degree: null,
        origin: null,
        workplace: null,
      },

      // 表单参数
      form: {
        name: null,
        idcard: null,
        sn: null,
        sex: null,
        birthday: null,
        ethnicity: null,
        politics: null,
        degree: null,
        origin: null,
        workplace: null,
        arrange: null,
        position: null,
        avatar: null,
        phone: null,
        type: null,
        audit: null,
        evaluate: null,
        score: null,
        ext1: null,
        ext2: null
      },
      //评价总览
      drawer: false,
      overviewForm: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询待评价人员列表 */
    getList() {
      this.loading = true;
      listMember(this.queryParams).then(response => {
        this.memberList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //打开综合评价总览
    handleView(row) {
      overview(row.id).then((res) => {
        this.drawer = true;
        this.form = res.data.member;
        this.overviewForm = res.data.overviewEvalutionVos;
      });
    },
  }
};
</script>
<style lang="scss">
.custom-label {
  width: 120px;
}

.custom-label-2 {
  width: 50%;
}
</style>
<style lang="scss" scoped>
.member-header {
  margin-bottom: 10px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;

  .member-username {
    color: red;
    margin-right: 5px;
  }
}

.member-select-button {
  text-align: center;
  margin-top: 20px;
}
</style>
